package cn.gameo2o.controller.xzgl;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.gameo2o.pojo.O2o_commentmanage;
import cn.gameo2o.pojo.O2o_group;
import cn.gameo2o.service.xzgl.XiaoZuGuanLiService;
import cn.gameo2o.util.PageParam;

/**
 * 游戏小组管理controller
 * @author 李君
 *
 */
@RestController
@RequestMapping("/xzgl")
public class XiangMuGuanLiController {
	@Resource
	private XiaoZuGuanLiService xzService;

	public XiaoZuGuanLiService getXzService() {
		return xzService;
	}

	public void setXzService(XiaoZuGuanLiService xzService) {
		this.xzService = xzService;
	}
	@RequestMapping("/findAll")
	public PageParam findAll(@RequestParam(required=false)String hdname,@RequestParam(required=false)String zzid,@RequestParam(required=false)String zzname,@RequestParam(required=false)String xzname,@RequestParam() Integer pageSize,@RequestParam() Integer first){
		Map params=new HashMap();
		params.put("hdname", hdname);
		params.put("zzid",	Integer.parseInt(zzid));
		params.put("zzname", zzname);
		params.put("xzname", xzname);
		PageParam page=new PageParam();
		page.setPageSize(pageSize);
		page.setFirst(first);
		xzService.findYxxz(params, page);
		return page;
	}
	
	@RequestMapping("/findbyid")
	public O2o_group findbyid(@RequestParam()String id){
		return xzService.findYxxzById(Integer.parseInt(id));
	}
	@RequestMapping("/delete")
	public String delete(@RequestParam()String id){
		xzService.deleteYxxz(Integer.parseInt(id));
		return "删除成功";
	}
	@RequestMapping("/save")
	 public String save(@ModelAttribute O2o_group group,@RequestParam() Integer [] ids){
	        xzService.addYxxz(group, ids);
	        return "添加成功！";
	}
	@RequestMapping("/update")
	 public String update(@ModelAttribute O2o_group group){
		 	xzService.updateYxxz(group);
		 	return "修改成功！";
	 }
}
